//
//  ST_PinterestHomeGuidanceManager.swift
//  btvideo
//
//  Created by mac on 2020/4/14.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit
import SwiftyUserDefaults

class ST_PinterestHomeGuidanceManager: NSObject {

    static let shared = ST_PinterestHomeGuidanceManager()

//    MARK: - 查看活跃
    /**
     查看活跃   PS: Must Call in Main Thread
     */
    func get_look_active_person()->Bool{
        
        return UserDefaults.standard.bool(forKey: get_look_active_key())
        
    }

    /**
     当前用户解锁 查看活跃
     */
    func unlock_look_active_person(){
        main_thread_execute {
            UserDefaults.standard.set(true, forKey: self.get_look_active_key())
        }
        
    }

    /**
     获取当前【查看活跃】的Key
     */
    fileprivate func get_look_active_key()->String{
        
        return Defaults[DefaultsKeys.currentUserID] + "LookActivePerson"
    }
    
    
 //    MARK: - 查看新人
    
    /**
     查看新人
     */
    func get_look_new_girl()->Bool{
        return UserDefaults.standard.bool(forKey: get_look_new_girl_key())
    }

    /**
     当前用户 解锁 查看新人
     */
    func unlock_look_new_girl(){
        
        main_thread_execute {
            
            UserDefaults.standard.set(true, forKey: self.get_look_new_girl_key())
            
        }
    }

    fileprivate func get_look_new_girl_key()->String{
        
        return Defaults[DefaultsKeys.currentUserID] + "LookNewGirlKey"
    }
//    MARK: - “添加个人介绍”取消不显示
    /**
     是否隐藏 “添加个人介绍”
     */
    func get_hidden_add_intro()->Bool{
        return UserDefaults.standard.bool(forKey: get_hidden_add_intro_key())
    }

    /**
     添加个人介绍 隐藏
     */
    func hidden_add_intro(){
        main_thread_execute {
            UserDefaults.standard.set(true, forKey: self.get_hidden_add_intro_key())
        }
    }

    fileprivate func get_hidden_add_intro_key()->String{
        
        return Defaults[DefaultsKeys.currentUserID] + "hiddenAddIntro"
    }
    
    /*
//    MARK:// - “完善个人资料”取消不显示
    /**
     是否隐藏 “完善个人资料”
     */
    func get_hidden_complete_intro()->Bool{
        return UserDefaults.standard.bool(forKey: get_hidden_complete_key())
    }

    /**
     完善个人资料 隐藏
     */
    func hidden_complete_intro(){
        
        UserDefaults.standard.set(true, forKey: get_hidden_complete_key())
    }

    fileprivate func get_hidden_complete_key()->String{
        
        return Defaults[DefaultsKeys.currentUserID] + "hiddenComplete"
    }
    */
    
    
}


//MARK: - Refresh Base Data
extension ST_PinterestHomeGuidanceManager{
    
    /**
     弃用
     */
    func refreshUserBaseConst(){
        
        /*
        let dispatchQueue = DispatchQueue(label: "RefreshUserBaseConstQueue", qos: .background)
        
        JVrequest(PH.otherPeopleNewInfoApi, parameters: ["target_accid":Defaults[DefaultsKeys.currentUserID]], autoPushLoginViewController: false, queue: dispatchQueue, success: { (json) in
            
//            self.viewModel = ST_PairsUserCenterViewModel.deserialize(from: json["data"])
            
            guard let pairsModel = ST_PairsUserModel.deserialize(from: json["data"].rawString() ?? "" ) else{
                print("数据结构不对")
                return
            }
            
            let albums = ST_PairsShareParticularModel.describe(json_array: json["data"]["album"].arrayValue)
            
            let information = json["data"]["information"]
            
            for item in pairsModel.own_feature{
                
                for pecDetail in item.detail{
                    //1.如果用户传了至少1个通过审核的特质，“添加特质”变为“查看活跃的人”
                    if pecDetail.state != 1{
                        self.unlock_look_active_person()
                        continue
                    }
                }
            }
            
//            2.如果用户传了至少2张照片在相册，“添加照片”变为“查看新人”
            if albums.count >= 2{
                self.unlock_look_new_girl()
            }
            
            
            let personal_desc = information["personal_desc"].stringValue
            
//            3.如果用户填写了“个人介绍”，“添加个人介绍”取消不显示
            if !personal_desc.isEmpty ||  personal_desc != ""{
                self.hidden_add_intro()
            }
            
        }) { (code, error) in
            print("调试 获取 用户 基础信息 错误❌:",error)
        }
        
        
//
        
        */
        
    }
    
    
}
